﻿var rate = $.cookie("RingRate") || 1;
var inlay;
var orderID;
var scrollToph;
var  notbtn=""; //1有按钮
var app_url=location.origin;
var curstate = 0; //当前类别选项
var datalist = {};

(function(){
	OrderSearch();
	var order={
		init:function(){
			//导航栏的选中
            $('.wrapper').navbarscroll();
            $("#categories li").eq(2).addClass("cur").siblings().removeClass("cur");
			this.BindEvents();
		},
		BindEvents:function(){
			var self = this;
			if(APP){
				$("#order_term_btn").remove();
			}

			 //售价算价格
             $("#_confirmPrice").bind('input propertychange',function(){
                var val=Number($(this).val());
                var rate=Number($("#_salesRate").val());
                var usd_p=formatUSDPrice(val/rate);
                $("#_BEFPrice").val(usd_p);
            });
            $("#_BEFPrice").bind('input propertychange',function(){
                var val=Number($(this).val());
                var rate=Number($("#_salesRate").val());
                var usd_r=formatUSDPrice(val*rate);
                $("#_confirmPrice").val(usd_r);
            });
            $("#_salesRate").bind('input propertychange',function(){
                var rate=Number($(this).val());
                var val=Number($("#_confirmPrice").val());
                var usd_p=formatUSDPrice(val/rate);
                $("#_BEFPrice").val(usd_p);
            });
            //筛选
            $("#order_term_btn").on("click", function () {
                if(APP){
                	var appJson={};
            		appJson.title=_("订单筛选");
            		appJson.url=app_url+"/Team/OrderFilter/?type=3";
            		YiYi_APP.showNewPage(JSON.stringify(appJson));
                }else{
                	location.href="/Team/OrderFilter/?type=3";
                }
            });
            $(".order-status span").on("click", function () { //订单状态选中
                $(this).addClass("active").siblings().removeClass("active");
            });
            //其他筛选条件点击添加样式、可多选
            $("#order_term_box").on("click", ".term span", function () {
                $(this).toggleClass("active");
            });
            $("#filter_product_btn").on("click", function () {
                $("#common_header").show();
                $("#order_term_btn").show();
                $("#order_term_box").hide();
                OrderSearch();
            });
			//点击全选
			$("#checkbox_check_all").on("click",function(){
				self.countCheck(0,0,0);//取消
				$(this).toggleClass("selected")
				if($(this).hasClass("selected")){
					$("#order .check_list_box").children("span").addClass("selected");
					$("#order .check_list_box span.selected").each(function (i, item) {
						var pre = parseFloat($(item).closest("li").find(".first").text());//当前点击行的每卡

    					var totalprice = parseFloat($(item).closest("li").find(".CurrentRMB .product_list_price_rmb").attr('data-PurchaseRMB'));
    					var usd_totalprice = parseFloat($(item).closest("li").find(".CurrentUSD .product_list_price_usd").attr('data-PurchaseUSD'));
    					handleBtn();
						self.countCheck(1,pre,totalprice);
						self.countCheck(1,pre,usd_totalprice,"usd");
					});		
				}else{
					$(".check_list_box").children("span").removeClass("selected");
					clearAll();
					self.countCheck(0,0,0);//取消
				}
			});
			//列表的勾选框
			$("#order").on("click",".check_list_box",function(){
				$(this).children("span").toggleClass("selected");
				var pre = parseFloat($(this).closest("li").find(".first").text());//当前点击行的每卡

                var totalprice = parseFloat($(this).closest("li").find(".CurrentRMB .product_list_price_rmb").attr('data-PurchaseRMB'));
                var usd_totalprice = parseFloat($(this).closest("li").find(".CurrentUSD .product_list_price_usd").attr('data-PurchaseUSD'));

				//判断是否全选
				var length=$("#order .check_list_box span.checkbox").length;
				var checkLength=$("#order .check_list_box span.selected").length;
				if(checkLength>0){
					handleBtn();
				}else{
					clearAll();
				}
				
				if(length==checkLength){
					$("#checkbox_check_all").addClass("selected");
				}else{
					$("#checkbox_check_all").removeClass("selected");
				}				
				if($(this).children("span").hasClass("selected")){
					self.countCheck(1,pre,totalprice);//选中

					self.countCheck(1,pre,usd_totalprice,"usd");//选中
				}else{
					self.countCheck(2,pre,totalprice);//取消
					self.countCheck(2,pre,usd_totalprice,"usd");//取消
				}
				
			});

				//采购订单输入验证 class=purchase_form
			var validate = $("#purchase_form").validate({
				debug: true, //调试模式取消submit的默认提交功能   
				focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
				onkeyup: false,
				submitHandler: function(form) { //表单提交句柄,为一回调函数，带一个参数：form   
					PurchaseOrder(); //采购订单
				},
				rules: {
					MainColor: "required",
					MainClarity: "required",
					PurchaseRMB: "required",
					OriginSN: "required",
					MainType: "required", //主石类型
					Material: "required",
					Category: "required",
					Style: "required",
					IsStock: "required",
					Measurement: "required",
					Weight: "required",
					MainWeight: "required",
					SideWeight: "required",
				},
				messages: {
					MainColor: "",
					MainClarity: "",
					PurchaseRMB: "",
					OriginSN: "",
					MainType: "", //主石类型
					Material: "",
					Category: "",
					Style: "",
					IsStock: "",
					Measurement: "",
					Weight: "",
					MainWeight: "",
					SideWeight: "",
		
				}
			});
		
			//回裸钻库输入验证 class=_backdia
			var validate = $("._backdia").validate({
				debug: true, //调试模式取消submit的默认提交功能   
				focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
				onkeyup: false,
				submitHandler: function(form) { //表单提交句柄,为一回调函数，带一个参数：form   
					BackDia(); //添加裸钻(回裸钻库)
				},
				rules: {
					OriginSN: "required",
					Weight: "required",
					MainShape: "required",
					MainColor: "required",
					MainClarity: "required",
					DeliveryTime: "required",
					SupplierCode: "required",
					CertNo: "required",
					PriceUSD: "required",
					Milky: "required",
					Hue: "required",
					Status: "required",
					Place: "required",
				},
				messages: {
					OriginSN: "",
					Weight: "",
					MainShape: "",
					MainColor: "",
					MainClarity: "",
					DeliveryTime: "",
					SupplierCode: "",
					CertNo: "",
					PriceUSD: "",
					Milky: "",
					Hue: "",
					Status: "",
					Place: "",
				}
			});
		},

        //统计数据
        countCheck:function(type,pre,totalPrice,usd){			
			var price=Number($("#check-total-price").text());
			var usd_price=parseFloat($("#check-total-price-usd").text());
			var pre_price=parseFloat($("#check-m-rmb").text());
			var _num = $(".check_list_box span.selected").length;;	
			if(type==1){//加				
				if(usd=="usd"){
					usd_price+=totalPrice
				}else{
					price+=totalPrice
					pre_price+=pre
				}
			}
			if(type==2){//减
				
				if(usd=="usd"){
					usd_price-=totalPrice
				}else{
					price-=totalPrice
					pre_price-=pre
				}
			}
			if(type==0){
				_num=0;
				price=0;
				usd_price=0;
				pre_price=0;
			}
			$("#check-num").text(_num);
			$("#check-m-rmb").text(formatRMBPrice(pre_price));
			// if(menu_team_rings_columns_ConfirmPrice){
				$("#check-total-price").text(formatRMBPrice(price));
			// }else{
            //     $("#check-total-price").text('-');
			// }
			// if(menu_team_rings_columns_ConfirmUSD){
				$("#check-total-price-usd").text(formatUSDPrice(usd_price));
			// }else{
            //     $("#check-total-price-usd").text('-');
			// }
		},

		
	}
	order.init();
})();
 

//绑定数据
function BindingOrder(result) {
    var _result = eval('(' + result + ')');//eval()解析单个json对象
    if (_result.msgcode == false) {//获取库存失败
        $("#order_list").html('<div style="text-align:center;padding-top:20px;width:100%;">'+_(_result.msginfo)+'</div>');
    } else { //获取库存成功
		_result = _result.msginfo;
        var lis = "";//多行数据
        for (var i = 0; i < _result.length ; i++) {//_result.length
			var li = ""; //单行
			var data = _result[i];
			var data_parse=JSON.parse(data.InventoryAttribute);
			var otherPar = "";
			var otherPar1 = "";
			var otherPar2 = "";
			var otherPar3 = "";

			if(data_parse.Category!=1){
				otherPar +="<b class='color'>"+GetText("inlays",data_parse.Category,data_parse.MainColor,"MainColor")+"</b>"+
				"<b  class='mainCertNo'>"+data_parse.MainCertNo+"</b><b class='mainCertType'>"+data_parse.MainCertType+"</b><b class='certType'>"+data_parse.CertType+"</b>";
			}
			if(data_parse.Category==2||data_parse.Category==3){
				otherPar1 +="<b class='mainClarity'>"+GetText("inlays",data_parse.Category,data_parse.MainClarity,"MainClarity")+"</b>";
			}
			if(data_parse.Category==4||data_parse.Category==5){
				 otherPar2 +="<b class='process'>"+GetText("inlays",data_parse.Category,data_parse.Process,"Process")+"</b>";
			}
			if(data_parse.Category>3){
				otherPar3 +="<b class='place'>"+GetText("inlays",data_parse.Category,data_parse.Place,"Place")+"</b>";
			}
			var ring_order_PurchaseRMB='';
			if(menu_team_rings_columns_ConfirmPrice){
				ring_order_PurchaseRMB="<span class='CurrentRMB' >￥<b class='product_list_price_rmb'  data-PurchaseRMB='"+data.PurchaseRMB+"'>" + formatRMBPrice(data.ConfirmRMB) +"</b></span>"
			}
			var ring_order_PurchaseUSD='';
			if(menu_team_rings_columns_ConfirmUSD){
                ring_order_PurchaseUSD="<span class='CurrentUSD'>$<b class='product_list_price_usd' data-PurchaseUSD='"+data.PurchaseUSD+"'>" + formatUSDPrice(data.ConfirmUSD) +"</b></span>"
			}

            lis += "<li>"+
            "<div>"+
            "<div class='check_list_box' lang='"+data.CustomerID+"' data-weight='"+ data.InventoryCount +"' data-first='"+data.ConfirmRMB+"' data-second='"+data.ConfirmUSD+"'" +
				"data-receiptStatus='"+data.PaymentStatus+"'  data-PaymentStatus='"+data.ReceiptStatus+"'   data-Balance='"+data.Balance+"' " +
				" data-USDBalance='"+data.USDBalance+"' >"+  //lang='"+data.ReceiptStatus+"' data-customerID='"+data.CustomerID+"'
            "<span class='checkbox' name='checkbox' lang='" + data.OrderID + "' data='"+data.OrderStatus+"'></span></div>"+
            "<div class='product_list' data-id="+data.OrderID +">"+
            "<label class='product-parameter' data-mainW='"+data_parse.MainWeight+"' data-sideW='"+data_parse.SideWeight+"' data='"+data.Remarks+
            "' data-id='"+data.OrderID+"'  data-sn='"+data_parse.OriginSN+"' data-pay='"+data.ReceiptStatus+"' lang='"+
            data.SalesExchangerate+"' style='display:none'></label>"+
            "<div class='list_img_box'>"+ShowImgOne(data_parse)+"</div>"+
			"<div class='list_detail_box'>"+
			"<p id='spec_list'>"+
			"<b class='category' data='"+data_parse.Category+"'>" + GetCategory("inlays",data_parse.Category) + "</b><b title='货号' class='originSN'>"+data_parse.OriginSN+"</b>" +
            "<b class='shape' >" + GetText("inlays",data_parse.Category,data_parse.MainShape,"MainShape") + "</b>"+
			"<b class='material' >" + GetText("inlays",data_parse.Category,data_parse.Material,"Material") + "</b>" +
            "<b class='type'>" + GetText("inlays",data_parse.Category,data_parse.Type,"Type") + "</b><b class='style'>" + GetText("inlays",data_parse.Category,data_parse.Style,"Style") + "</b>" +
            "<b class='place'>" + GetText("inlays",data_parse.Category,data_parse.Country,"Country") + "</b><b class='measurement'>"+data_parse.Measurement+"</b>"+
            "<b class='weight'>" + data_parse.Weight + "</b><b class='Series'>" + data_parse.Series + "</b>"+otherPar+otherPar1+otherPar2+otherPar3+
			"</p>"+
			"<div class='list_price'>"+
				ring_order_PurchaseRMB+ring_order_PurchaseUSD+
			"</span><span class='status_box' style='margin-left:10px'>"+ReceiptStatusFormat(data.PaymentStatus)+"</span><span class='status_box' lang='"+data.OrderStatus+"'>"+UserOrderStatusFormat(data.OrderStatus)+"</span></div>"+
			"<div class='time_box'>"+_("下单日期")+"：<span class='order-time'>"+DateTimeFormat(data.CreateTime)+"</span></div>"+
			"</div></div>"+modify_boxsRing(data)+
			"</li>";

			lis += li;//将单行加到多行
        }
        $("#order_list").html(lis);//加入到id为inventory的figures中
        currentShow();  //币种设置
        //   @*主题色start*@
	    $(document.createElement("script")).attr("src","/Js/ThemesColor.js").appendTo("html");
	    //  @*主题色end*@
    }
}
        
   
//自留回库 12-15
function BackDia_Js(me,gwRate) {
	categoryTypeShow(me);
    $.ajax({
        url: "/Team/GetRingOrderInfo",
        type: "POST",
        data: "{'OrderID':'" + me.getAttribute("value") + "'}",
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            var _result = eval('(' + result + ')');
            if(_result.msgcode==true){
            _result = _result.msginfo;
            var data = _result;
            myApp.popup(".BackDia_box");

            $("#_orID").val(_result.OrderID);//12-16
            $("#_invID").val(_result.ID);
            $("#originSN").val(_result.OriginSN);
            $("#category").val(GetCategory("inlays",data.Category));
            $("#mainClarity").val(data.MainClarity);   //主石净度 
            $("#process").val(data.Process);
            $("#mainShape").val(_result.MainShape);
            $("#series").val(_result.Series);
            $("#mainColor").val(data.MainColor); //颜色
            
            $("#weight").val(_result.Weight);
            $("#sideWeight").val(_result.SideWeight);
            $("#mainWeight").val(_result.MainWeight);
			$("#material").val(_result.Material); //材质
            $("#isStock").val(data.IsStock);  //
            $("#certType").val(_result.CertType);
            
            $("#style").val(_result.Style);
            $("#countryState").val(_result.Country+_result.State); //所在地
            $("#place").val(_result.Place); //产地
            $("#mainCertType").val(_result.MainCertType);
            $("#measurement").val(_result.Measurement);
            $("#type").val(data.Type);
            $("#mainCertNo").val(_result.MainCertNo);
            
            $("#remark").val(_result.Remark);
            $("#onShelves").val(_result.OnShelves);

//          //原采购部分 01-12
            $("#back_purchaseExchange").val(_result.PurchaseExchangerate);//01-12采购汇率
            $("#sourceRMBGrain").val(Math.round(_result.PurchaseRMB)); //原人民币
            var back_purchaseRMBperCarat =Math.round((_result.PurchaseRMB / parseFloat($("#back_purchaseExchange").val())) / _result.Weight);
            $("#back_purchaseRMBperCarat").val((Math.round(_result.PurchaseRMB / _result.Weight))); //采购人民币每卡
            $("#sourceUSDPerGrain").val(Math.round(_result.PurchaseRMB / parseFloat($("#back_purchaseExchange").val())));//原美金
            $("#back_purchaseUSDPerCarat").val(Math.round(_result.PurchaseRMB / parseFloat($("#back_purchaseExchange").val()) / _result.Weight));//01-12  carat/usd采购美金每卡
        
//          //买
//          $("#buyUSDPerGrain").val(_result.PriceUSD);//01-12 买美金
//          $("#buyRMBGrain").val((_result.ConfirmPrice / (100 + _result.Confirmdiscount) * (100 + _result.DiscountReturn)).toFixed(2));//01-12买RMB

 			}else{
                $(".BackDia_box").hide();
                toast(_(_result.msginfo));     	
           	}

        }
    });
}    
//回库12-16
function BackDia(me) {
	var requestDia = {};

	requestDia.OrderID = $("#_orID").val(); //12-16

	requestDia.OriginSN = $("#originSN").val();
	requestDia.Category = $("#category").val();
	requestDia.MainClarity = $("#mainClarity").val();
	requestDia.Process = $("#process").val();
	requestDia.MainShape = $("#mainShape").val();
	requestDia.Series = $("#series").val();
	requestDia.MainColor = $("#mainColor").val();

	requestDia.Weight = $("#weight").val();
	requestDia.SideWeight = $("#sideWeight").val();
	requestDia.MainWeight = $("#mainWeight").val();
	requestDia.Material = $("#material").val();
	requestDia.IsStock = $("#isStock").val();
	requestDia.CertType = $("#certType").val();

	requestDia.Style = $("#style").val();
	requestDia.Country = $("#countryState").val();
    requestDia.Place = $("#_place").val(); //产地
	requestDia.MainCertType = $("#mainCertType").val();
	requestDia.Measurement = $("#measurement").val();
	requestDia.Type = $("#type").val();
	requestDia.MainCertNo = $("#mainCertNo").val();
	requestDia.Remark = $("#remark").val();
	requestDia.OnShelves = $("#onShelves").val(); //上下架 12-28            

	//          原采购
	requestDia.PurchaseExchangerate = $("#back_purchaseExchange").val(); //原采购汇率
	//			requestDia.PurchaseRMBperCarat = $("#back_purchaseRMBperCarat").val();//原采购每卡￥
	//			requestDia.PurchaseUSDPerCarat = (parseFloat($("#back_purchaseRMBperCarat").val()) / parseFloat($("#back_purchaseExchange").val())).toFixed(2); //$("#back_purchaseUSDPerCarat").val();//原采购每卡$
	requestDia.ConfirmPrice = (parseFloat($("#back_purchaseRMBperCarat").val()) * parseFloat($("#weight").val())).toFixed(1); // $("#sourceRMBGrain").val(); //原采购总价￥
	requestDia.PurchaseUSDPerGrain = (parseFloat($("#back_purchaseRMBperCarat").val()) * parseFloat($("#weight").val()) * parseFloat($("#back_purchaseExchange").val())).toFixed(2); //$("#back_purchaseUSDPerGrain").val();//原采购总价$

	//          //买
	requestDia.BuyUSDPerGrain = $("#buyUSDPerGrain").val(); //买美金
	requestDia.BuyRMBGrain = $("#buyRMBGrain").val(); //买人民币

	$.ajax({
		url: "/Team/RingstockOrders", 
		type: "POST",
		data: JSON.stringify(requestDia),
		contentType: "application/json; charset=utf-8",
		success: function(result) {
			var _result = eval('(' + result + ')');

			if(_result.msgcode == false) {
				//添加失败(接口错误或程序内部错误)
				myApp.alert(_("新增失败")+"：" + _result.msginfo);
			} else {
				//添加成功
				if(_result.result == true) {
					//{\"count\": 1, \"ids_insert\": [5158997], \"ids\": [5158997], \"ids_update\": [], \"result\": true, \"count_update\": 0, \"count_insert\": 1}
					myApp.alert(_("成功条目")+"：" + _result.count + _("\n\n新增条目")+"：" + _result.count_insert + _("\n\n更新条目")+"：" + _result.count_update);
					myApp.closeModal(".BackDia_box"); //回库框关闭
					OrderSearch();
				} else {
					//请求参数不符{\"msg\": \"\\u4ef7\\u683c\\u8f6c\\u6362\\u5931\\u8d25\", \"result\": false}
					myApp.alert(_("新增失败")+"：" + _(_result.msg));
				}
			}
		}
	});
}

//采购订单
function modify_box(me) {

	categoryTypeShow(me); //对应成品主石类型显示参数
	currentPurShow(); //采购的币种设置
	//          currentPurShow(); //采购币种
	var categoryValue = $(me).attr("lang");


	$.ajax({
		url: "/Team/GetOrderNew", //提交地址
		type: "POST", //提交方式
		data: "{'OrderID':'" + me.getAttribute("value") + "','GoodsType':3}",
		contentType: "application/json; charset=utf-8",
		success: function(result) {
			var _result = eval('(' + result + ')'); //eval()解析单个json对象
			if(_result.msgcode==true){
                _result = _result.msginfo;
				var data = _result;
				var data_parse=JSON.parse(data.InventoryAttribute)
                myApp.popup(".modify_pop_box");
            //基本信息
			$("#_orderID").val(_result.OrderID);
			$("#_orderStat").val(_result.OrderStatus); //隐藏域11-3 
			$("#_weight").val(data_parse.Weight);
			$("#_mainWeight").val(data_parse.MainWeight);
			$("#_sideWeight").val(data_parse.SideWeight);
			$("#_certType").val(data_parse.CertType); //证书类型（成品）
			//                  $("#_no").val(_result.CertNo);
			$("#_price").val(_result.ConfirmPrice);
			$("#_styleNo").val(_result.StyleNo);
			$("#_size").val(data_parse.Measurement);
			$("#_originSN").val(data_parse.OriginSN);
			$("#_series").val(data_parse.Series);
			$("#_Material").val(data_parse.Material.toUpperCase()); //材质
			$("#_style").val(data_parse.Style);
			$("#_isStock").val(data_parse.IsStock);
			$("#_category").val(data_parse.Category); //Category类别（主石类型:空托，白钻，彩钻）
			$("#_mainType").val(data_parse.Type); //Type 类型（戒指、耳环等）
			$("#_mainCertType").val(data_parse.MainCertType); //主石证书类型
			$("#_mainNo").val(data_parse.MainCertNo); //主石证书号
			$("#_mainColor").val(data_parse.MainColor);
			$("#_mainClarity").val(data_parse.MainClarity);
			$("#_supplier").val(_result.Supplier);
			$("#_countryState").val(data_parse.Country); //所在地
			$("#_place").val(data_parse.Place); //产地
			$("#_mainShape").val(data_parse.MainShape); //主石形状

			//                  $("#_Confirmdiscount").val(_result.Confirmdiscount);  
			$("#_purchaseExchange").val(_result.PurchaseExchangerate);
			$("#_PurchaseRemarks").val(_result.PurchaseRemarks);
			$("#_deliveryTime").val(DateTimeFormat(_result.ShipTime));
			$("#_buyPriceUSD").val(PriceFormat(parseFloat(_result.PurchaseUSD).toFixed(2))); //买美金
			$("#_buyPrice").val(PriceFormat(parseFloat(_result.PurchaseRMB).toFixed(1))); //买人民币
            }else{
                $(".modify_pop_box").hide();
                toast(_(_result.msginfo));
            }

		}
	});
}
 
//采购订单8-20
function PurchaseOrder(me) {
	myApp.showPreloader(_("修改中，请稍等!"));
	//          computeUsd();//确定之前已退点为准再计算一次 10-15

	var requestOrder = {};

	requestOrder.OrderID = $("#_orderID").val();
	requestOrder.CertType = $("#_certType").val();
	requestOrder.OriginSN = $("#_originSN").val();
	requestOrder.Weight = $("#_weight").val();
	requestOrder.MainWeight = $("#_mainWeight").val();
	requestOrder.SideWeight = $("#_sideWeight").val();
	requestOrder.CertNo = $("#_no").val();
	requestOrder.ConfirmPrice = $("#_price").val();
	requestOrder.Measurement = $("#_size").val();
	requestOrder.Series = $("#_series").val();
	requestOrder.StyleNo = $("#_styleNo").val();
	requestOrder.Material = $("#_quality").val();
	requestOrder.Style = $("#_style").val();
	requestOrder.IsStock = $("#_isStock").val();
	requestOrder.Category = $("#_category").val();
	requestOrder.Type = $("#_mainType").val();
	requestOrder.MainCertType = $("#_mainCertType").val();
	requestOrder.MainCertNo = $("#_mainNo").val();
	requestOrder.MainColor = $("#_mainColor").val();
	requestOrder.MainClarity = $("#_mainClarity").val();
	requestOrder.ShipTime = $("#_deliveryTime").val();
	//买价
	requestOrder.PurchaseExchangerate = $("#_purchaseExchange").val(); //采购汇率
	requestOrder.PurchaseRMB = $("#_buyPrice").val(); //买RMB
	requestOrder.PriceUSD = $("#_buyPriceUSD").val();; //买美金	
	requestOrder.Country = $("#_countryState").val(); //所在地
	requestOrder.MainShape = $("#_mainShape").val(); //主石形状
	requestOrder.Place = $("#_place").val(); //产地
	requestOrder.OrderStatus=$("#_orderStat").val();

	$.ajax({
		url: "/team/PurchaseOrderNew", 
		type: "POST", 
		data: JSON.stringify(requestOrder),
		contentType: "application/json; charset=utf-8",
		success: function(result) {
			myApp.hidePreloader(); 
			var _result = eval('(' + result + ')'); 
			myApp.alert(_(_result.msginfo),function(){
				myApp.closeModal(".modify_pop_box"); 
				OrderSearch();
			});
			                   
		}
	});
}

function categoryTypeShow(type) {
	var type = $(type).attr("lang");
	//处理
	if(type == 4 || type == 5 || type == 6 || type == 7 || type == 8) {
		$(".process").show();
		} else {
		$(".process").hide();
	}

	// if(type != 1) {
	// 	$(".MainColor").show();
	// 	$(".MainClarity").hide();
	// 	$(".place").show();
	// 	$(".MainCertNo").show();
	// 	$(".MainCertType").show();
	// 	$(".CertType").show();
	// } else {
	// 	$(".MainColor").hide();
	// 	$(".MainClarity").hide();
	// 	$(".place").hide();
	// 	$(".MainCertNo").hide();
	// 	$(".MainCertType").hide();
	// 	$(".CertType").hide();
	// }
	//颜色
    if(type != 1) {
        var $color = "";
        for(var i = 0; i < inlay[type].MainColor.length; i++) {
            $color += '<option value="' + inlay[type].MainColor[i][0] + '">' + inlay[type].MainColor[i][1] + '</option>';
        }
        var $certType= "";
        for(var i = 0; i < inlay[type].CertType.length; i++) {
            $certType += '<option value="' + inlay[type].CertType[i][0] + '">' + inlay[type].CertType[i][1] + '</option>';
        }

        var $maincertType= "";
        for(var i = 0; i < inlay[type].MainCertType.length; i++) {
            $maincertType += '<option value="' + inlay[type].MainCertType[i][0] + '">' + inlay[type].MainCertType[i][1] + '</option>';
        }
        $("#_mainCertType,#back_MainCertType").html($maincertType);
        $("#_mainColor,#back_MianColr").html($color);
        $("#_certType,#back_CertType").html($certType);
        $(".MainColor").show();
        $(".MainCertNo").show();
		$(".MainCertType").show();
		$(".place").show();
        $(".CertType").show();
    } else {
		$(".MainColor").hide();
		$(".place").hide();
        $(".MainCertNo").hide();
        $(".MainCertType").hide();
        $(".CertType").hide();
    }

	if(type == 2 || type == 3) {
		$(".MainColor").show();
		$(".MainClarity").show();
		$(".place").hide();
	}

	    //净度
	if(type == 2 || type == 3) {
		var $clarity = "";
		for(var i = 0; i < inlay[type].MainClarity.length; i++) {
			// console.log(inlay[type].MainClarity[i][0])
			$clarity += '<option value="' + inlay[type].MainClarity[i][0] + '">' + inlay[type].MainClarity[i][1] + '</option>';
		}
		$("#_mainClarity,#MainClarity").html($clarity);
		$(".MainClarity").show();
	}else{
		$(".clarity").hide();
	}

}

   
